home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / OTSTARS.ZIP / stars3d.doc < prev    next >
Text File  |  1996-02-06  |  4KB  |  92 lines

  1.  
  2.                       - THE OUTLAW TRIAD DEMO-SERIES -
  3.  
  4. ─────────────────────────────────■ PART II ■─────────────────────────────────
  5.  
  6.                            Written by : Vulture/OT
  7.                            Code in    : Pascal/Asm
  8.                            Topic      : 3d starfield
  9.  
  10. ──────────────────────────────■ Introduction ■───────────────────────────────
  11.  
  12.  Welcome to the Outlaw Triad demo-series! In these series we will be talking
  13.  about programming demo-effects in either pascal or assembler. Theory behind
  14.  the effects shall be discussed while a full sourcecode is also provided.
  15.  In this second release of the Outlaw Triad demo-series we will discuss how
  16.  to create a 3d starfield in 100% assembler. This is a wellknown effect in
  17.  the demo-scene and is used in many demos. It's a great background routine
  18.  for various effects so let's see how one creates such a starfield. Enjoy!
  19.  
  20. ─────────────────────────────────■ Theory ■──────────────────────────────────
  21.  
  22.  A 3d point consists of X,Y,Z values. However, your screen is a 2d
  23.  plane. This means you must do a 3d to 2d conversion. You can do that
  24.  with these formulas:
  25.  
  26.    ScreenX := ((X * 256) / Z) + 160
  27.    ScreenY := ((Y * 256) / Z) + 100
  28.  
  29.  I assume ScreenX and ScreenY don't need any futher explanation.
  30.  Now, setup X to be a random value between -160..160. Your Y value should be
  31.  setup between -100..100. I choose Z to be 256 at start. When decreasing the
  32.  Z value, the stars will come towards you. Obviously, when you increase Z,
  33.  stars will fly away from you. You add 160 and 100 to center the point on
  34.  the screen. Ok, if the star Z value is 0 (or below), then abort the star
  35.  and create a new one. Also do this when the star is not in VGA range.
  36.  In my code I did these steps:
  37.  
  38.  - Check Z (and do appropiate action)
  39.  - Delete old star
  40.  - Calculate Screen X
  41.  - Range check X
  42.  - Calculate Screen Y
  43.  - Range check Y
  44.  - Calculate final vga-position (y*320+x)
  45.  - Plot star
  46.  - Save vgaposition (for deletion)
  47.  - Decrease (or increase) Z
  48.  
  49.  Do this for all stars and that's it! You've got a cool 3d starfield!
  50.  
  51.  The little trick in this source is the Random routine. When I first started
  52.  coding assembler, I examined an example of 3d stars by Draeden of VLA.
  53.  His example used a chart with the random values pre-calculated in it. This
  54.  is a nice solution but the disadvantage is that you will always see the same
  55.  stars because you work with the same random values constantly. That's not
  56.  too good. So, when I finally got my own random routine, I decided to write
  57.  my own little 3d starfield. The starting seed value is obtained from the
  58.  system clock, just like using the Randomize command in Pascal.
  59.  
  60.  Of course you can do various little tricks with 3d starfields. For example,
  61.  you could rotate all stars so they fly in another direction. What I'm trying
  62.  to say is that a simple basic 3d starfield ain't nothing special. So go and
  63.  make something cool using 3d starfields. Try implementing this in other
  64.  resolutions (like 320*400). Be creative!
  65.  
  66.  Ok, this is all for now. Happy coding!
  67.  
  68.         - Vulture / Outlaw Triad -
  69.  
  70. ───────────────────────────────■ Distro Sites ■──────────────────────────────
  71.  
  72.  Call our distros to get all our releases.
  73.  
  74.   BlueNose        World HQ     +31 (0)345-619401
  75.   FireHouse       Distrosite   +31 (0)528-274176         More distros wanted!
  76.   The Force       Distrosite   +31 (0)36-5346967
  77.   MagicWare       Italian HQ   +39  6-52355532
  78.  
  79. ──────────────────────────────────■ Contact ■────────────────────────────────
  80.  
  81.  Want to contact Outlaw Triad for some reason? You can reach us at our
  82.  distrosites in Holland. Or if you have e-mail access, mail us:
  83.  
  84.    Vulture  (coder/pr)     comma400@tem.nhl.nl
  85.  
  86.  Our internet homepage:
  87.  
  88.    http://www.tem.nhl.nl/~comma400/vulture.html
  89.  
  90.  These internet adresses should be valid at least till june 1996.
  91.  
  92. ──────────────────────────────────────────────────────────────────────────────